package com.bdqn.Practice.service;

import com.bdqn.Practice.pojo.SysRole;
import com.bdqn.Practice.pojo.SysUser;
import com.bdqn.Practice.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service("sysUserService") // 注册为一个Service层的Bean
public class SysUserServiceImpl implements SysUserService {
    @Autowired // @Resource // 使用注解的方式将DAO层的Bean注入
    private SysUserMapper sysUserMapper;
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<SysUser> selectSysUserList() {
        try {
            return sysUserMapper.selectSysUserList();
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public List<SysUser> SysUserList(SysUser sysUser) {
        try {
            return sysUserMapper.SysUserList(sysUser);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int add(SysRole sysRole) {
        return sysUserMapper.add(sysRole);
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int delete(int id) {
        return sysUserMapper.delete(id);
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int update(SysRole sysRole) {
        return sysUserMapper.update(sysRole);
    }

    public SysUserMapper getSysUserMapper() {
        return sysUserMapper;
    }

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }

}
